﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using DBAccess;
using Logic;
using WHUT;

public partial class tokenTeam_members : System.Web.UI.Page
{
    private const string TITLE = "部门成员";
    protected string introduce = string.Empty;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            BindMember();
            BindIntr();
        }
    }

    // Bind Member
    private void BindMember()
    {
        DataTable dt = Common.SQLQueryAsDataTable(Common.GetDefaultDBConnection(), "SELECT [id],[name] FROM [t_dept] WHERE [id] <> 8  ORDER BY [name] ASC");
        rptMember.DataSource = dt;
        rptMember.DataBind();
    }

    protected void repDept_ItemDataBound(object source, RepeaterItemEventArgs e)
    {
        string selStr = string.Empty;
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater rep = e.Item.FindControl("rptDept") as Repeater;//找到里层的repeater对象
            DataRowView rowv = (DataRowView)e.Item.DataItem; //找到分类Repeater关联的数据项 
            String deptId = Convert.ToString(rowv["Id"]);

            selStr = "SELECT [pic_url],[name] FROM [t_user] WHERE [dept_id]=" + deptId + " ORDER BY [name] ASC";
            DataTable dt = Common.SQLQueryAsDataTable(Common.GetDefaultDBConnection(), selStr);
            rep.DataSource = dt;
            rep.DataBind();
        }
    }

    private void BindIntr() 
    {
        Introduce into = (new Introduce()).LoadByTags(TITLE);
        introduce = into.Content;
    }
}
